package com.example.controller;

import com.example.common.Result;
import com.example.service.StatisticsService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/statistics")
public class StatisticsController {

    @Resource
    private StatisticsService statisticsService;

    @GetMapping("/homeOverview")
    public Result getHomeOverview() {
        Map<String, Object> statistics = statisticsService.getHomeOverview();
        return Result.success(statistics);
    }
    
    @GetMapping("/overview")
    public Result getOverview() {
        Map<String, Object> overview = statisticsService.getOverview();
        return Result.success(overview);
    }
    
    @GetMapping("/bookingTrend")
    public Result getBookingTrend(@RequestParam String timeRange) {
        Map<String, Object> trend = statisticsService.getBookingTrend(timeRange);
        return Result.success(trend);
    }
    
    @GetMapping("/roomTypeDistribution")
    public Result getRoomTypeDistribution() {
        return Result.success(statisticsService.getRoomTypeDistribution());
    }
    
    @GetMapping("/hotelRanking")
    public Result getHotelRanking() {
        Map<String, Object> ranking = statisticsService.getHotelRanking();
        return Result.success(ranking);
    }
} 